<template>
  <ul class="right_list_container">
    <li v-for="(item, index) in list" :key="index">
      <span @click="handlerItem(item)" :class="{ active: item.isSelect }">{{
        item.name
      }}</span>
      <RightList :list="item.children" @select="handlerItem" />
    </li>
  </ul>
</template>

<script>
export default {
  name: "RightList",
  // list数据结构：[ { name: "xxx" , isSelect: true , children: [ { name: "xxx" , isSelect: true ] } ]
  props: {
    list: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    handlerItem(item) {
      this.$emit("select", item);
    },
  },
};
</script>

<style lang="less" scoped>
@import "~@/styles/var.less";
.right_list_container {
  list-style: none;
  padding: 0;
  .right_list_container {
    margin-left: 1em;
  }
  li {
    min-height: 40px;
    line-height: 40px;
    cursor: pointer;
    .active {
      color: @warn;
      font-weight: bold;
    }
  }
}
</style>
